package com.markyao.controller.recos;

import com.markyao.service.db.ConfigInfoService;
import com.markyao.vo.ConfigInfoVo;
import com.markyao.vo.QueryParams;
import com.markyao.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/recos/configinfo")
public class ConfigInfoController {

    @Autowired
    ConfigInfoService configInfoService;

    @PostMapping("list")
    public Result list(@RequestBody QueryParams queryParams){
        return configInfoService.selectList(queryParams);
    }

    @PostMapping("add")
    public Result addOne(@RequestBody ConfigInfoVo configInfoVo){
        return configInfoService.insert(configInfoVo);
    }

    @PostMapping("update")
    public Result updateOne(@RequestBody ConfigInfoVo configInfoVo){
        return configInfoService.update(configInfoVo);
    }

    @PostMapping("delete")
    public Result deleteBatch(@RequestBody String[] ids){
        return configInfoService.deletes(ids);
    }

    @GetMapping("getOne/{id}")
    public Result getOne(@PathVariable("id") String id){
        QueryParams queryParams = new QueryParams();
        queryParams.setId(id);
        ConfigInfoVo configInfoVo = configInfoService.select(queryParams);
        return Result.success(configInfoVo);
    }

}
